package com.qfedu.service.impl;

import com.qfedu.dao.LoginAdmin;
import com.qfedu.entity.Admin;
import com.qfedu.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author:huayuzhuo
 * @email:2798866329@qq.com
 * @desc:
 * @datatime: 2022/10/30 12:22
 */
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private LoginAdmin loginAdmin;

    @Override
    public Admin adminLogin(String username, String password) {
        Admin admin = loginAdmin.adminLogin(username);
        if (null == admin) {
            System.out.println(new RuntimeException("用户不存在"));
        }

        if (!password.equals(admin.getPassword())) {
            throw new RuntimeException("密码错误");
        }
        return admin;
    }

}
